package View;

import java.awt.Point;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;


public class ViewEingabe extends JDialog {
	private static final long serialVersionUID = 1L;
	
	private JLabel lbMessage = new JLabel();
	private JLabel lbKontoNr = new JLabel();
	private JLabel lbKontostand = new JLabel();
	
	private JTextField tfMessage = new JTextField();
	private JTextField tfKontoNr = new JTextField();
	private JTextField tfKontostand = new JTextField();
	private JButton btnSend = new JButton();
	private JComboBox<String> cbTask = new JComboBox<String>();
	
	public ViewEingabe() {
		init();
		registerEvents();
	}
	
	public void init() {
		initWindow();
		
		initLbMessage();
		initLbKontoNr();
		initLbKontostand();
		
		initTfMessage();
		initTfKontoNr();
		initTfKontostand();
		
		initCbTask();
		
		initBtnSend();
		
		setVisible(true);
	}
	
	public void initWindow() {
		setLayout(null);
		setSize(450, 400);
		setLocation(new Point(200, 100));
		setResizable(false);		
	}
	
	private void initLbMessage() {
		lbMessage.setText("Inhaber");
		lbMessage.setBounds(16, 32, 100, 23);
		add(lbMessage);
	}
	
	private void initLbKontoNr() {
		lbKontoNr.setText("KontoNr.");
		lbKontoNr.setBounds(16, 64, 100, 23);
		add(lbKontoNr);
	}

	private void initLbKontostand() {
		lbKontostand.setText("Kontostand");
		lbKontostand.setBounds(16, 96, 100, 23);
		add(lbKontostand);
	}
	
	public void initTfMessage() {
		tfMessage.setBounds(132, 32, 144, 23);
		add(tfMessage);
	}
	
	public void initTfKontoNr() {
		tfKontoNr.setBounds(132, 64, 144, 23);
		add(tfKontoNr);
	}
	
	public void initTfKontostand() {
		tfKontostand.setBounds(132, 96, 144, 23);
		add(tfKontostand);
	}
	
	public void initCbTask() {
		cbTask.setBounds(16, 128, 100, 23);
		cbTask.addItem("INSERT");
		cbTask.addItem("UPDATE");
		cbTask.addItem("DELETE");
		
		add(cbTask);
	}
	
	public void initBtnSend() {
		btnSend.setText("Senden");
		btnSend.setBounds(16, 160, 100, 23);
		add(btnSend);
	}
	
	private void registerEvents() {
		addWindowListener(new windowListener());
	}

	class windowListener extends WindowAdapter {
		public void windowClosing(WindowEvent e) {
			e.getWindow().dispose();
			System.exit(0);
		}
	}

	public JLabel getLbMessage() {
		return lbMessage;
	}

	public void setLbMessage(JLabel lbMessage) {
		this.lbMessage = lbMessage;
	}

	public JTextField getTfMessage() {
		return tfMessage;
	}

	public JTextField getTfKontoNr() {
		return tfKontoNr;
	}

	public void setTfKontoNr(JTextField tfKontoNr) {
		this.tfKontoNr = tfKontoNr;
	}

	public JTextField getTfKontostand() {
		return tfKontostand;
	}

	public void setTfKontostand(JTextField tfKontostand) {
		this.tfKontostand = tfKontostand;
	}

	public void setTfMessage(JTextField tfMessage) {
		this.tfMessage = tfMessage;
	}
	
	public JComboBox<String> getCbTask() {
		return cbTask;
	}

	public void setCbTask(JComboBox<String> cbTask) {
		this.cbTask = cbTask;
	}

	public JButton getBtnSend() {
		return btnSend;
	}

	public void setBtnSend(JButton btnSend) {
		this.btnSend = btnSend;
	}	
}
